import random

class Solution:
    def findKthLargest(self, nums, k):
        def quick_select(nums, k):
            if len(nums) == 0:
                return None
            
            pivot = random.choice(nums)
            big, equal, small = [], [], []
            for num in nums:
                if num > pivot:
                    big.append(num)
                elif num < pivot:
                    small.append(num)
                else:
                    equal.append(num)
            if k <= len(big):
                return quick_select(big, k)
            if k > len(nums) - len(small):
                return quick_select(small, k - len(nums) + len(small))
            return pivot
        
        return quick_select(nums, k)
